#include <QGuiApplication>
#include <QQmlApplicationEngine>

#include <QLocale>
#include <QTranslator>
#include <QQuickStyle>
#include "tool.h"
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QQuickStyle::setStyle("Material");


    // Tool::getStaticTool()->KCFanalysis();
    qmlRegisterSingletonInstance<Tool>("Tool", 1, 0, "Tool", Tool::getStaticTool());
    QTranslator translator;

    const QStringList uiLanguages = QLocale::system().uiLanguages();
    for (const QString &locale : uiLanguages) {
        const QString baseName = "codenest_client_" + QLocale(locale).name();
        if (translator.load(":/i18n/" + baseName)) {
            app.installTranslator(&translator);
            break;
        }
    }
   // qmlRegisterSingletonInstance("Bi",1,0,"Bi_c",c_basic_information::f_cbi());
    // qmlRegisterSingletonInstance("tool",1,0,"tool",Tool::getStaticTool());

    QQmlApplicationEngine engine;

    // emit Tool::getStaticTool()->joctoqml();
    const QUrl url(QStringLiteral("qrc:/codenest_client/main.qml"));
    QObject::connect(
        &engine,
        &QQmlApplicationEngine::objectCreated,
        &app,
        [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        },
        Qt::QueuedConnection);
    // Tool::getStaticTool()->KCFanalysis();


    engine.load(url);
    QObject *rootObject = engine.rootObjects().isEmpty() ? nullptr : engine.rootObjects().first();
    if (rootObject) {
        // emit Tool::getStaticTool()->joctoqml();  // 发射信号
        Tool::getStaticTool()->KCFanalysis();
    }
    Tool::getStaticTool()->connectToServer();
    Tool::getStaticTool()->checkToLoginAuto();
    app.exec();
    // connect(app,&QGuiApplication::)
     return 0;
}
